package com.lq.schoolshop.service.impl;

import com.lq.schoolshop.dao.UserMapper;
import com.lq.schoolshop.pojo.Expand.UserExamp;
import com.lq.schoolshop.pojo.User;
import com.lq.schoolshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author
 * @Date2021/1/5 22:27
 * @Version V1.0
 * 用户业务类
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public UserExamp showall(int id) {
        return userMapper.showall(id);
    }

    @Override
    public User login(String username, String password) {
        return userMapper.login(username,password);
    }

    @Override
    public String getlogoImg(String username) {
        return userMapper.getlogoImg(username);
    }

    @Override
    public String getlogoImgById(int id) {
        return userMapper.getlogoImgById(id);
    }

    @Override
    public int updateImg(int id, String icon) {
        return userMapper.updateImg(id,icon);
    }

    @Override
    public int updateuserinfo(String name, String phone, String address, int id) {
        return userMapper.updateuserinfo(name,phone,address,id);
    }

    @Transactional
    @Override
    public int updatePassword(String password, int uid) {
        return userMapper.updatePassword(password,uid);
    }

    @Transactional
    @Override
    public int regislogi(String sex ,String username, String password, String name, String secretkey) {
        int regislogi = 0;
        try {
            regislogi = userMapper.regislogi(sex,username, password, name, secretkey);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return regislogi;
    }


    @Override
    public int exist(String username) {
        return userMapper.exist(username);
    }

    @Override
    public int complain(String username, String secretkey) {
        return userMapper.complain(username,secretkey);
    }

    @Override
    public int updateByUUID(String secretkey, String username) {
        return userMapper.updateByUUID(secretkey,username);
    }

    @Override
    public int updatePwdByname(String username, String password) {
        return userMapper.updatePwdByname(username,password);
    }

    @Override
    public int updatetoken(int id, String tokensecrekey) {
        return userMapper.updatetoken(id,tokensecrekey);
    }

    @Override
    public int selByIdAndToken(int id, String tokensecrekey) {
        return userMapper.selByIdAndToken(id,tokensecrekey);
    }


}
